package com.hzdl.house_mgr.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzdl.house_mgr.bean.Menu;
import com.hzdl.house_mgr.mapper.MenuMapper;
import com.hzdl.house_mgr.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> findById(Integer id) {
        return menuMapper.findById(id);
    }

    @Override
    public PageInfo<Menu> findByWhere(String name,Integer page,Integer limit,Integer id) {
        PageHelper.startPage(page,limit);
        List<Menu> list = menuMapper.findByWhere(name,id);
        PageInfo<Menu> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Integer getCountByWhere(String name,Integer id) {
        return menuMapper.getCountByWhere(name,id);
    }

    @Override
    public int addMenu(Menu menu) {
        return menuMapper.addMenu(menu);
    }

    @Override
    public int delMenu(Integer id) {
        return menuMapper.delMenu(id);
    }

    @Override
    public int updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public int findByPid(Integer id) {
        return menuMapper.findByPid(id);
    }

    @Override
    public List<Menu> findAll() {
        return menuMapper.findAll();
    }

    @Override
    public List<Menu> findMenuByRoleId(Integer roleId) {
        return menuMapper.findMenuByRoleId(roleId);
    }

    @Override
    public List<Menu> findByUserId(Integer userId) {
        return menuMapper.findByUserId(userId);
    }
}
